package com.springboot.cloud.demos.ribbon.rest;

import com.springboot.cloud.common.core.entity.vo.Result;
import com.springboot.cloud.demos.entity.form.UserPositionForm;
import com.springboot.cloud.demos.entity.po.UserPosition;
import com.springboot.cloud.demos.ribbon.service.UserPositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserPositionController {

    @Autowired
    private UserPositionService userPositionService;

    @GetMapping("/userPosition/query")
    public Result<UserPosition> query(@RequestParam("userId") String userId) {
        return userPositionService.query(userId);
    }

    @GetMapping("/userPosition/{id}")
    public Result<UserPosition> get(@PathVariable(value = "id") String id) {
        return userPositionService.get(id);
    }

    @DeleteMapping("/userPosition/{id}")
    public Result delete(@PathVariable(value = "id") String id) {
        return userPositionService.delete(id);
    }

    @PostMapping("/userPosition")
    public Result add(@RequestBody UserPositionForm userPositionForm) {
        return userPositionService.save(userPositionForm);
    }

    @PutMapping(value = "/userPosition")
    public Result update(@RequestBody UserPositionForm userPositionForm) {
        return userPositionService.update(userPositionForm);
    }
}
